<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
        <el-header>
		<div class="left-panel">
                <div class="right-panel-search">
                    <div class="search-input">工序名称</div>
                    <el-input v-model="orderNumber" placeholder="请输入工序名称" />
                    <el-button type="primary" icon="el-icon-search" @click="upsearch">搜索</el-button>
                </div>
            </div>
        </el-header>
        <el-main class="nopadding">
            <scTable ref="table" :apiObj="apiObj" @select-all="selectAll" @selection-change="selectionChange" stripe remoteSort remoteFilter border height='400' hideDo>
                <el-table-column type="selection" width="50"></el-table-column>
                <!-- <el-table-column label="工序名称" prop="title" align="center"></el-table-column> -->
                <el-table-column label="工序名称" prop="mode_name" align="center"></el-table-column>
            </scTable>
        </el-main>
		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
			<el-button v-if="mode != 'show'" type="primary" @click="back" :disabled="selection.length == 0">选择</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '选择工序',
				edit: '选择工序',
				show: '查看'
			},
			visible: false,
			isSaveing: false,
            // apiObj: this.$API.setting.gongXu.lists,
            apiObj: this.$API.develop.template.lists,
            selection: [],
            wuIndex:''
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
        selectionChange(selection) {
            if(selection.length > 1){
                const del_row = selection.shift()
                this.$refs.table.toggleRowSelection(del_row,false) //设置这一行取消选中
            }else{
                this.selection = selection;
            }
		},
        back(){
            this.$emit('success', this.selection, this.wuIndex)
            this.visible = false;
        },
        setData(data) {
			this.wuIndex = data.index
		},
        selectAll() {
            this.$message.error("请选择一条数据！")
            this.$refs.table.clearSelection()
        },
	}
}
</script>

<style></style>
